package com.example.demo.Test;

import com.example.demo.common.BinaryTool;
import com.example.demo.mqserver.core.Message;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张
 * Date: 2024-08-15
 * Time: 9:51
 */
public class BinaryTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        String content = "testMessage";
        Message expectMessage = Message.createMessageWithId("TestMessageKey",null,content.getBytes(StandardCharsets.UTF_8));
        System.out.println("expectMessage.getBody = " + expectMessage.getBody());
        Message actualMessage = (Message) BinaryTool.fromBytes(BinaryTool.toBytes(expectMessage));
        System.out.println("actualMessage.getBody = " + actualMessage.getBody());
        System.out.println("expectMessage : " + expectMessage.toString());
        System.out.println("actualMessage : " + actualMessage.toString());
    }
}
